package com.anjho.pojo;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "estate")
@NamedQueries(value = {
		@NamedQuery(name = "Estate.getEstateList", query = "SELECT e FROM Estate e"),
		@NamedQuery(name = "Estate.getEstateById", query = "SELECT e FROM Estate e WHERE e.escode = :escode")
})
public class Estate implements Serializable {

	private static final long serialVersionUID = 4904907938957979302L;
	
	public Estate() {
		this.setEscode(0);
		this.setAcronym("");
		this.setName("");
	}
	
	@Id
	@Column(name="escode")
	@OneToMany(mappedBy="estate")
	private int escode;
	
	@Column(name="acronym", nullable=false, length=2)
	private String acronym;
	
	@Column(name="name", nullable=false, length=72)
	private String name;

	public int getEscode() {
		return escode;
	}

	public void setEscode(int escode) {
		this.escode = escode;
	}

	public String getAcronym() {
		return acronym;
	}

	public void setAcronym(String acronym) {
		this.acronym = acronym;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + escode;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Estate other = (Estate) obj;
		if (escode != other.escode)
			return false;
		return true;
	}
}
